// Qt on Metro Stub
// Copyright (c) Andrew Knight
// This software is licensed under the MIT: http://www.opensource.org/licenses/MIT

// Based on code from http://code.msdn.microsoft.com/windowsapps/Direct2D-Basic-Animation-d0a5a4d1, original license:
//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////
//// Copyright (c) Microsoft Corporation. All rights reserved

#include <winrt.h>
#include "DirectXBase.h"

#include <QtGui/QApplication>
#include <QtGui/QGraphicsScene>
#include <QtGui/QPainter>
#include <QtGui/QMouseEvent>
#include "../metro/metroapplication.h"

using namespace Windows::Foundation;

ref class QtClient : public DirectXBase
{

public:
    QtClient(MetroApplication* metroApp);
	virtual void Initialize(Windows::UI::Core::CoreWindow^ window, float dpi) override;
    virtual void CreateDeviceResources() override;
    virtual void CreateWindowSizeDependentResources() override;
    virtual void Render() override;
	
	void OnPointerPressed(
        _In_ Windows::UI::Core::CoreWindow^ sender,
        _In_ Windows::UI::Core::PointerEventArgs^ args
        );

    void OnPointerMoved(
        _In_ Windows::UI::Core::CoreWindow^ sender,
        _In_ Windows::UI::Core::PointerEventArgs^ args
        );

    void OnPointerReleased(
        _In_ Windows::UI::Core::CoreWindow^ sender,
        _In_ Windows::UI::Core::PointerEventArgs^ args
        );

    void OnPointerWheelChanged(
        _In_ Windows::UI::Core::CoreWindow^ sender,
        _In_ Windows::UI::Core::PointerEventArgs^ args
        );

	void OnLayoutChanged(
		_In_ Windows::UI::ViewManagement::ApplicationLayout^ sender,
		_In_ Windows::UI::ViewManagement::ApplicationLayoutChangedEventArgs^ args
		);

private:
	// WinRT types
	Microsoft::WRL::ComPtr<ID2D1Bitmap> m_bitmap;

	// Qt types
	MetroApplication* metroApp;

	// Utility methods
	QMouseEvent PointerArgsToMouseEvent(QEvent::Type type, Windows::UI::Core::PointerEventArgs^ args);

};
